C++11 终止一个thread对象表示的线程

您所在的位置:网站首页 c++ 线程退出 C++11 终止一个thread对象表示的线程

C++11 终止一个thread对象表示的线程

2024-07-11 03:00| 来源: 网络整理| 查看: 265

“terminate 1 thread + forcefully (target thread doesn’t cooperate) + pure C++11 = No way”. 233333

对于Linux/GCC,可以用pthread.h里的pthread_cancel来强行杀死某一线程。 注意thread对象的析构函数并不会把线程杀死。

code:

#include #include #include #include using namespace std; void foo() { size_t x = 0; while (1) { cout


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3